home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / misc / fpl-v13.lha / fpl / src / script.h < prev    next >
C/C++ Source or Header  |  1995-08-22  |  46KB  |  1,267 lines

  1. /******************************************************************************
  2.  *                   FREXX PROGRAMMING LANGUAGE                  *
  3.  ******************************************************************************
  4.  
  5.  Script.h
  6.  
  7.  Script structures and defines!
  8.  
  9.  *****************************************************************************/
  10.  
  11. /************************************************************************
  12.  *                                                                      *
  13.  * fpl.library - A shared library interpreting script langauge.         *
  14.  * Copyright (C) 1992-1994 FrexxWare                                    *
  15.  * Author: Daniel Stenberg                                              *
  16.  *                                                                      *
  17.  * This program is free software; you may redistribute for non          *
  18.  * commercial purposes only. Commercial programs must have a written    *
  19.  * permission from the author to use FPL. FPL is *NOT* public domain!   *
  20.  * Any provided source code is only for reference and for assurance     *
  21.  * that users should be able to compile FPL on any operating system     *
  22.  * he/she wants to use it in!                                           *
  23.  *                                                                      *
  24.  * You may not change, resource, patch files or in any way reverse      *
  25.  * engineer anything in the FPL package.                                *
  26.  *                                                                      *
  27.  * This program is distributed in the hope that it will be useful,      *
  28.  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
  29.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                 *
  30.  *                                                                      *
  31.  * Daniel Stenberg                                                      *
  32.  * Ankdammsgatan 36, 4tr                                                *
  33.  * S-171 43 Solna                                                       *
  34.  * Sweden                                                               *
  35.  *                                                                      *
  36.  * FidoNet 2:201/328    email:dast@sth.frontec.se                       *
  37.  *                                                                      *
  38.  ************************************************************************/
  39.  
  40. #define OUTDATE_OLD /* to outdate the old error enums! */
  41.  
  42. #include <string.h>
  43. #include "FPL.h"
  44. #if defined(AMIGA) && defined(SHARED)
  45. #include "LibAlloc.h" /* stack allocation routines */
  46. #endif
  47.  
  48. /**********************************************************************
  49.  *
  50.  * Global defines:
  51.  *
  52.  *********************************************************************/
  53.  
  54. #ifndef  TRUE
  55. #define  TRUE    1
  56. #endif
  57. #ifndef  FALSE
  58. #define  FALSE    0
  59. #endif
  60.  
  61. #define FPLTEXT_UNKNOWN_PROGRAM "<unknown program>"
  62. /* When requesting the name of a program, and no program is available or no
  63.    name has been given. This string will be returned! */
  64.  
  65. #define MAX_DIMS         40  /* Maximum number of array dimensions */
  66. #define IDENTIFIER_LEN       64
  67. /* maximum number of characters in a function-, variable- or label name
  68.    ANSI C Standard X3J11 states that there should be at least "31
  69.    significant initial characters in an internal identifier or a macro name" */
  70. #define ADDSTRING_DEFAULT     16  /* default length of a string expression */
  71. #define ADDSTRING_INC         63  /* string expression length increase step */
  72. #define MAX_ARGUMENTS         63  /* number of parsed function arguments
  73.                      before realloc is done */
  74.  
  75. #define FPL_HASH_SIZE 67
  76. /* Default hash table size. This should not be dividable with 2, 3, 4 or 5 */
  77.  
  78. #define FPL_MIN_HASH 10
  79. /* The smallest acceptable hash table size */
  80.  
  81. #define BUF_SIZE (IDENTIFIER_LEN+3) /* "global" FPL buffer size */
  82.  
  83. #if defined(AMIGA) && defined(SHARED)
  84. #define FPL_MIN_STACK 8000  /* smallest required stack */
  85. #define FPL_MAX_STACK 20000 /* maximum stack left after a run */
  86. #define FPL_MAX_LIMIT 40000 /* default maximum stack use possible */
  87.  
  88. #define FPLSTACK_MINIMUM 1000 /* Stack margin. When the stack space is below,
  89.                  this, than realloc to a bigger one! */
  90. #endif
  91.  
  92. #define BLOCK_ENTRIES 16    /* Number of free-block entries in the
  93.                    free-block array */
  94. #define MEMORY_QUEUE_SIZE 20    /* number of free blocks in the queue */
  95.  
  96. #define MEMORY_QUEUE    1    /* Yes, we'll use the memory queuing system! */
  97.  
  98. #define ALLOCBIT    (1<<31) /* set if MALLOC_STATIC */
  99. #define SIZEBITS    ~ALLOCBIT
  100.  
  101. #ifdef DEBUG
  102. #define MEMORY_COOKIE    0    /* When using the DEBUG option, all Malloc()
  103.                    will allocate a number of extra bytes at
  104.                    the end of the block. These will be checked
  105.                    to be intact when the block is freed or
  106.                    CheckMem()'ed. This #define tells the size
  107.                    of that block! */
  108.  
  109. #define PRE_COOKIE    0    /* Makes all allocations allocate this many
  110.                    bytes extra before the block! */
  111.  
  112. #define DEBUGPARAMETERS1 , AREG(1) uchar *source, DREG(2) long line
  113. #define DEBUGPARAMETERS2 , uchar *source, long line
  114.  
  115.  
  116. #else
  117. #define MEMORY_COOKIE 0
  118. #endif
  119.  
  120. /*
  121.  * Flags to use with the exists() function:
  122.  */
  123. #define EXISTS_FUNCTION 'f'
  124. #define EXISTS_VARIABLE 'v'
  125. #define EXISTS_STRING   's'
  126. #define EXISTS_INTEGER  'i'
  127.  
  128. /**********************************************************************
  129.  *
  130.  * Different character defines:
  131.  *
  132.  **********************************************************************/
  133.  
  134. #define _U (1<<0)  /* upper case */
  135. #define _L (1<<1)  /* lower case */
  136. #define _W (1<<2)  /* also included as a valid identifier character */
  137. #define _N (1<<3)  /* numerical digit 0-9 */
  138. #define _S (1<<4)  /* white space */
  139. #define _C (1<<5)  /* control character */
  140. #define _P (1<<6)  /* punctation characters */
  141. #define _X (1<<7)  /* hexadecimal digit */
  142.  
  143. extern const uchar type[257];
  144.  
  145. #define CHAR_OPEN_BRACE    '{'
  146. #define CHAR_CLOSE_BRACE   '}'
  147. #define CHAR_OPEN_PAREN    '('
  148. #define CHAR_CLOSE_PAREN   ')'
  149. #define CHAR_OPEN_BRACKET  '['
  150. #define CHAR_CLOSE_BRACKET ']'
  151. #define CHAR_COMMA         ','
  152. #define CHAR_SEMICOLON     ';'
  153. #define CHAR_PLUS          '+'
  154. #define CHAR_MINUS         '-'
  155. #define CHAR_ONCE_COMPLEMENT '~'
  156. #define CHAR_NOT_OPERATOR  '!'
  157. #define CHAR_MULTIPLY      '*'
  158. #define CHAR_DIVIDE        '/'
  159. #define CHAR_AND           '&'
  160. #define CHAR_OR            '|'
  161. #define CHAR_XOR           '^'
  162. #define CHAR_REMAIN        '%'
  163. #define CHAR_QUESTION      '?'
  164. #define CHAR_COLON         ':'
  165. #define CHAR_ASSIGN        '='
  166. #define CHAR_LESS_THAN     '<'
  167. #define CHAR_GREATER_THAN  '>'
  168. #define CHAR_SPACE         ' '
  169. #define CHAR_DOLLAR       '$'
  170. #define CHAR_HASH       '#'
  171. #define CHAR_ZERO          '0'
  172. #define CHAR_ONE           '1'
  173. #define CHAR_TWO           '2'
  174. #define CHAR_THREE         '3'
  175. #define CHAR_FOUR          '4'
  176. #define CHAR_FIVE          '5'
  177. #define CHAR_SIX           '6'
  178. #define CHAR_SEVEN         '7'
  179. #define CHAR_EIGHT         '8'
  180. #define CHAR_NINE          '9'
  181. #define CHAR_UPPER_A       'A'
  182. #define CHAR_A             'a'
  183. #define CHAR_UPPER_B       'B'
  184. #define CHAR_B             'b'
  185. #define CHAR_UPPER_C       'C'
  186. #define CHAR_C             'c'
  187. #define CHAR_D             'd'
  188. #define CHAR_F             'f'
  189. #define CHAR_UPPER_I       'I'
  190. #define CHAR_I             'i'
  191. #define CHAR_UPPER_N       'N'
  192. #define CHAR_N             'n'
  193. #define CHAR_O             'o'
  194. #define CHAR_R             'r'
  195. #define CHAR_UPPER_S       'S'
  196. #define CHAR_S             's'
  197. #define CHAR_T             't'
  198. #define CHAR_V             'v'
  199. #define CHAR_UPPER_X       'X'
  200. #define CHAR_X             'x'
  201. #define CHAR_APOSTROPHE    '\''
  202. #define CHAR_NEWLINE       '\n'
  203. #define CHAR_VERTICAL_TAB  '\v'
  204. #define CHAR_CARRIAGE_RETURN '\r'
  205. #define CHAR_ALERT         '\a'
  206. #define CHAR_QUOTATION_MARK '\"'
  207. #define CHAR_BACKSLASH     '\\'
  208. #define CHAR_FORMFEED      '\f'
  209. #define CHAR_BACKSPACE     '\b'
  210. #define CHAR_TAB           '\t'
  211. #define CHAR_ASCII_ZERO    '\0'
  212.  
  213. #define CASE_BIT  ('a'-'A')
  214.  
  215. /**********************************************************************
  216.  *
  217.  * A bunch of useful enums:
  218.  *
  219.  **********************************************************************/
  220.  
  221. typedef enum {          /* all FPL operators */
  222.   OP_NOTHING, OP_PLUS, OP_MINUS, OP_DIVISION, OP_MULTIPLY,  OP_SHIFTL,
  223.   OP_SHIFTR, OP_REMAIN, OP_BINAND, OP_BINOR, OP_BINXOR, OP_LOGAND,
  224.   OP_LOGOR, OP_COMPL, OP_COND1, OP_COND2, OP_EQUAL, OP_LESSEQ, OP_GRETEQ,
  225.   OP_LESS, OP_GRET, OP_NOTEQ, OP_NOT,
  226.  
  227.   OP_PREINC, /* pre increment */
  228.   OP_PREDEC  /* pre decrement */
  229. #ifdef NEXT_GENERATION
  230.     , OP_COMMA, OP_ASSIGN, OP_PLUSASSIGN, OP_MINUSASSIGN,
  231.     OP_ORASSIGN, OP_XORASSIGN, OP_ANDASSIGN, OP_LSHIFTASSIGN, OP_RSHIFT_ASSIGN,
  232.     OP_REMAINASIGN, OP_MULASSIGN
  233. #endif
  234.     } Operator;
  235.  
  236. typedef enum { /* the internal functions and keywords */
  237.   CMD_AUTO=-200,
  238.   CMD_BREAK,
  239.   CMD_CASE,
  240.   CMD_CONST,
  241.   CMD_CONTINUE,
  242.   CMD_DEFAULT,
  243.   CMD_DO,
  244.   CMD_DOUBLE,
  245.   CMD_ENUM,
  246.   CMD_EXIT,
  247.   CMD_EXPORT,
  248.   CMD_FLOAT,
  249.   CMD_FOR,
  250.   CMD_IF,
  251.   CMD_INT,
  252.   CMD_REGISTER,
  253.   CMD_RESIZE,
  254.   CMD_RETURN,
  255.   CMD_SIGNED,
  256.   CMD_STATIC,
  257.   CMD_STRING,
  258.   CMD_STRUCT,
  259.   CMD_SWITCH,
  260.   CMD_TYPEDEF,
  261.   CMD_UNION,
  262.   CMD_UNSIGNED,
  263.   CMD_VOID,
  264.   CMD_VOLATILE,
  265.   CMD_WHILE,
  266.  
  267.   FNC_ABS=-100,
  268.   FNC_ATOI,
  269.   FNC_DEBUG,
  270.   FNC_EVAL,
  271.   FNC_EXISTS,
  272.   FNC_INTERPRET,
  273.   FNC_ITOA,
  274.   FNC_ITOC,
  275.   FNC_JOINSTR,
  276.   FNC_LTOSTR,
  277.   FNC_RENAME,
  278.   FNC_SPRINTF,
  279.   FNC_SSCANF,
  280.   FNC_STRCMP,
  281.   FNC_STRICMP,
  282.   FNC_STRISTR,
  283.   FNC_STRLEN,
  284.   FNC_STRNCMP,
  285.   FNC_STRNICMP,
  286.   FNC_STRSTR,
  287.   FNC_STRTOL,
  288.   FNC_SUBSTR,
  289.   FNC_OPENLIB, /* amiga only */
  290.   FNC_CLOSELIB, /* amiga only */
  291.  
  292.   LAST_INTERNAL /* must be the last of these ones! */
  293.   } Funcs;
  294.  
  295. #define KEYWORD_ELSE "else" /* the "else" keyword define !! */
  296.  
  297. /**********************************************************************
  298.  *
  299.  * Debug macro defines.
  300.  *
  301.  *********************************************************************/
  302.  
  303. #ifdef DEBUG
  304. /* If debugging, use the mem integer to debug the MALLOC/FREE balance! */
  305. extern long mem;
  306. extern long maxmem;
  307. #endif
  308.  
  309. /**********************************************************************
  310.  *
  311.  * Script() control bits:
  312.  *
  313.  *********************************************************************/
  314.  
  315. #define SCR_NORMAL  0   /* Nothing! */
  316. #define SCR_IF      (1<<0)
  317. #define SCR_WHILE   (1<<1)
  318. #define SCR_DO      (1<<2)
  319. #define SCR_FOR     (1<<3)
  320. #define SCR_LOOP    (SCR_WHILE|SCR_DO|SCR_FOR)
  321. #define SCR_FUNCTION (1<<4)
  322. #define SCR_BRACE   (1<<5) /* Declaration is allowed! This started with a brace -
  323.                  should end with a brace, return(), break or exit()
  324.                */
  325. #define SCR_RETURN_STRING (1<<6)/* This function is declared to return a string */
  326. #define SCR_GLOBAL (1<<7)
  327. #define SCR_SWITCH (1<<8)
  328. #define SCR_FILE   (1<<9)  /* this is the file level, on this level the program
  329.                               can end with a '\0' char! */
  330. #define SCR_DEBUG  (1<<10) /* this level runs in debug mode! */
  331.  
  332. /***********************************************************************
  333.  *
  334.  * Expression() control bits:
  335.  *
  336.  **********************************************************************/
  337.  
  338. #define CON_NORMAL     0      /* normal statement */
  339. #define CON_DECLINT    (1<<0) /* int declaration statement */
  340. #define CON_DECLSTR    (1<<1) /* string declaration statement */
  341. #define CON_GROUNDLVL  (1<<2) /* this statement starts at the ground level */
  342. #define CON_SEMICOLON  (1<<3) /* forces Statement() to return positive on ";"
  343.                  statement. Designed to support "for(;;)". */
  344. #define CON_PAREN      (1<<4) /* support for the last expression of the for(;;)
  345.                  ones */
  346. #define CON_ACTION     (1<<5) /* This flag forces Statement() to report errror
  347.                  if no "action" was made in the statement just
  348.                  parsed. */
  349. #define CON_END        (1<<6) /* Tell statement() there can be no
  350.                  "UNEXPECTED_END".*/
  351. #define CON_NUM        (1<<7) /* Only accept numerical statements! */
  352. #define CON_STRING     (1<<8) /* Hint about this being a string statement! */
  353. #define CON_DECLVOID   (1<<9) /* Declaration of a `void' function! */
  354. #define CON_DECLEXP    (1<<10) /* Declaration of an `export' symbol */
  355. #define CON_DECLGLOB   (1<<11) /* Declaration of a global symbol! */
  356. #define CON_IDENT      (1<<12) /* The local parameter points to an already
  357.                   parsed "struct Identifier" */
  358. #define CON_DECL8      (1<<13) /* Declaration of an eight bit variable */
  359. #define CON_DECL16     (1<<14) /* Declaration of an sixteen bit variable */
  360. #define CON_DECLUNSIGN (1<<15) /* Unsigned declaration */
  361. #define CON_DECLCONST  (1<<16) /* Constant declaration (read only) */
  362. #define CON_DECLSTATIC (1<<17) /* Static declaration */
  363.  
  364. #define CON_LEVELOK    (1<<18) /* Disables same "proper level" controls */
  365.  
  366. #define CON_LESSTHAN32 (CON_DECL8|CON_DECL16)
  367. #define CON_DECLARE (CON_DECLINT|CON_DECLSTR|CON_DECLVOID) /* declaration */
  368.  
  369. /***********************************************************************
  370.  *
  371.  * A bunch of useful macros:
  372.  *
  373.  **********************************************************************/
  374.  
  375. #define isalpha(c)  ((type+1)[c] & (_U|_L))
  376. #define isupper(c)  ((type+1)[c] & _U)
  377. #define islower(c)  ((type+1)[c] & _L)
  378. #define isdigit(c)  ((type+1)[c] & _N)
  379. #define isxdigit(c) ((type+1)[c] & _X)
  380. #define isalnum(c)  ((type+1)[c] & (_U|_L|_N))
  381. #define isspace(c)  ((type+1)[c] & _S)
  382. #define ispunct(c)  ((type+1)[c] & _P)
  383. #define isprint(c)  ((type+1)[c] & (_U|_L|_N|_P))
  384. #define iscntrl(c)  ((type+1)[c] & _C)
  385. #define isascii(c)  (!((c) & ~127))
  386. #define isgraph(c)  ((type+1)[c] & (_U|_L|_N|_P))
  387. #define toascii(c)  ((c) & 127)
  388. #define toupper(c)  ((type+1)[c] & _L? c-CASE_BIT: c)
  389. #define tolower(c)  ((type+1)[c] & _U? c+CASE_BIT: c)
  390.  
  391. #define isodigit(c) ((c) >= CHAR_ZERO && (c) <= CHAR_SEVEN)
  392.  
  393. #define isident(c)  ((type+1)[c] & (_U|_L|_W))
  394. #define isidentnum(c)  ((type+1)[c] & (_U|_L|_W|_N))
  395.  
  396.   /* CALL - macro performing the instruction inside parentheses and receiving
  397.      the return code in `ret'. If `ret' happens to become non-zero, a
  398.      "return(ret);" will be performed! */
  399. #define CALL(func) if(ret=(func)) return(ret)
  400.  
  401.   /* GETMEM - macro allocating memory and returning FPLERR_OUT_OF_MEMORY if it
  402.      fails! */
  403.  
  404. #define GETMEM(var,size) if(!(var=(void *)MALLOC(size))) \
  405.   return(FPLERR_OUT_OF_MEMORY);
  406.  
  407.   /* GETMEMA - macro allocating static memory and returning FPLERR_OUT_OF_MEMORY
  408.      if it fails! */
  409.  
  410. #define GETMEMA(var,size) if(!(var=(void *)MALLOCA(size))) \
  411.   return(FPLERR_OUT_OF_MEMORY);
  412.  
  413.   /* STRDUP - macro instead of the common strdup() ! */
  414.  
  415. #define STRDUP(var, pointer) \
  416.   GETMEM(var, strlen((uchar *)(pointer))+1);\
  417.   strcpy(var, (pointer));
  418.  
  419.   /* STRDUPA - macro instead of the common strdup() for STATIC allocs ! */
  420.  
  421. #define STRDUPA(var, pointer) \
  422.   GETMEMA(var, strlen((uchar *)(pointer))+1);\
  423.   strcpy(var, (uchar *)(pointer));
  424.  
  425.   /* UPPER - returns uppercase version any a-z character */
  426. #define UPPER(x) ((x)&~CASE_BIT)
  427.  
  428.   /* ABS - returns the absolute value of the argument */
  429. #define ABS(x) ((x)>0?x:-x)
  430.  
  431.   /* MIN - returns the minimum value of the two input arguments */
  432. #define MIN(x,y) ((x)<(y)?(x):(y))
  433.  
  434.   /* MIN3 - returns the minimum value of the three input arguments */
  435. #define MIN3(x,y,z) MIN( MIN((x),(y)) ,(z))
  436.  
  437.   /* Here follows the define for strdup() of a string stored in a
  438.      (struct fplStr *) */
  439. #define STRFPLDUP(dest,source)\
  440.    do {\
  441.      GETMEM(dest, sizeof(struct fplStr)+source->len); /* get string space */\
  442.      memcpy(dest->string, source->string, source->len); /* copy string */\
  443.      dest->len=dest->alloc=source->len; /* set alloc and length */\
  444.      dest->string[dest->len]='\0'; /* zero terminate! */\
  445.    } while(0)
  446.  
  447.  
  448. #define ASSIGN_OPERATOR ( \
  449.              (scr->text[0]==CHAR_ASSIGN &&        \
  450.               scr->text[1]!=CHAR_ASSIGN) ||        \
  451.              ((scr->text[0]==CHAR_PLUS ||        \
  452.               scr->text[0]==CHAR_MINUS ||        \
  453.               scr->text[0]==CHAR_MULTIPLY ||    \
  454.               scr->text[0]==CHAR_DIVIDE ||        \
  455.               scr->text[0]==CHAR_AND ||        \
  456.               scr->text[0]==CHAR_OR ||        \
  457.               scr->text[0]==CHAR_REMAIN ||        \
  458.               scr->text[0]==CHAR_XOR) &&        \
  459.              scr->text[1]==CHAR_ASSIGN) ||        \
  460.              !strncmp("<<=", scr->text, 3) ||    \
  461.              !strncmp(">>=", scr->text, 3)        \
  462.             )
  463.  
  464.  /* Get-file-date macro */
  465. #ifdef AMIGA
  466. #define GETFILEDATE(x) (x.fib_Date.ds_Days * 86400 +\
  467.                         x.fib_Date.ds_Minute * 60 +\
  468.                         x.fib_Date.ds_Tick / TICKS_PER_SECOND)
  469. #else
  470.       /* not done yet, fix when time exists! */
  471. #endif
  472.  
  473. /***********************************************************************
  474.  *
  475.  * Defines:
  476.  *
  477.  **********************************************************************/
  478.  
  479. #define MALLOC_DYNAMIC 0
  480. #define MALLOC_STATIC  1
  481.  
  482. #define FREE_KIND(x) FreeKind(scr, (void *)(x))
  483.  
  484. #ifdef DEBUG
  485. #define MALLOC(x) MallocCycle(scr, x, __FILE__, __LINE__)
  486. #define MALLOCA(x) Malloc(scr, (x), MALLOC_STATIC, __FILE__, __LINE__)
  487. #else
  488. #define MALLOC(x) MallocCycle(scr, x)
  489. #define MALLOCA(x) Malloc(scr, (x), MALLOC_STATIC)
  490. #endif
  491.  
  492. #define FREE(x) FreeCycle(scr, (void *)(x))
  493. #define FREEA(x) Free(scr, (void *)(x), MALLOC_STATIC)
  494.  
  495. #define FREEALL() FreeAll(scr, MALLOC_DYNAMIC)
  496. #define FREEALLA() FreeAll(scr, MALLOC_STATIC)
  497.  
  498. /* old version:
  499.    #define GETSTRLEN(str) ((long)*(long *)(str))
  500.    */
  501. #define GETSTRLEN(str) (((struct fplStr *)(((uchar *)str)-offsetof(struct fplStr, string)))->len)
  502.  
  503. #if defined(AMIGA)
  504.   /*
  505.    * We have to make all external referenced functions to receive the
  506.    * parameters in certain registers and restore the A4 register.
  507.    */
  508.  
  509. #define PREFIX __asm __saveds   /* special SAS/C ideas! Forces arguments
  510.                    to be puched in specified registers and
  511.                    forces the A6 register to be loaded at the
  512.                    beginning of the funtion. */
  513. #define AREG(x) register __a ## x
  514. #define DREG(x) register __d ## x
  515. #define REGARGS __regargs
  516. #define ASM __asm
  517.  
  518.  /***************************************
  519.   *
  520.   * funclib specific defines:
  521.   *
  522.   **************************************/
  523.  
  524. #define FPLLIB_SOURCE "FPLLIBS:"
  525. #define FPLLIB_OPENCMD "open "
  526. #define FPLLIB_CLOSECMD "close "
  527. #define FPLLIB_MAXSPACE 60 /* length of the command string */
  528.  
  529. #else
  530.   /*
  531.    * No need for any of those!
  532.    */
  533. #define PREFIX
  534. #define REGARGS
  535. #define AREG(x)
  536. #define DREG(x)
  537. #define ASM
  538. #endif
  539.  
  540. #if defined(AMIGA) /* the amiga library defines... */
  541. #define INLINE __inline
  542. #else
  543. #define INLINE
  544. #endif
  545.  
  546. /**********************************************************************
  547.  *
  548.  * Create some structures and define their flags:
  549.  *
  550.  *********************************************************************/
  551.  
  552. struct Unary {
  553.   Operator unary;
  554.   struct Unary *next;
  555. };
  556.  
  557. struct InsideFunction {
  558.   /*
  559.    * Used for `inside' functions.
  560.    */
  561.  
  562.   uchar ret;
  563.   uchar *format; 
  564.   
  565.   long col; /* column number of the inside function position. */
  566.   long prg; /* line number of the function */
  567.   uchar *file; /* name of file where this function resides */
  568.   long virprg; /* virtual line number */
  569.   uchar *virfile; /* virtual file name */
  570. };
  571.  
  572. struct ExternalFunction {
  573.   /*
  574.    * Used for all other functions and keywords.
  575.    */
  576.   uchar ret; /* 'I' - returns an integer
  577.            'S' - returns a string
  578.            */
  579.   uchar *format; /* Parameter format. Zero terminated. Unlimited length.
  580.            'I' - integer
  581.            'S' - string
  582.            'C' - string variable structure
  583.            'N' - integer variable structure
  584.            '>' - variable number of the previous type.
  585.  
  586.            NULL pointer - no argument at all.
  587.            lower case - optional (must only be to the right of
  588.            the required)
  589.              
  590.            Ex: "ISsc"
  591.            means that the function requires two parameters:
  592.            one integer and one string. It has two optional
  593.            parameters: one string and one string variable. */
  594.   long ID; /* Identifier ID. This information is sent in the
  595.           fplArgument structure.
  596.           <0 is reserved for FPL internals. */
  597.  
  598.   void *data; /* function specific data! */
  599.   long (*func)(void *); /* optional function! */
  600. };
  601.  
  602. struct fplStr {
  603.   /*
  604.    * FPL 'string' structure!
  605.    */
  606.   long alloc;     /* Allocated length of following string. That goes for the
  607.              string *only*! The structure's size have to be added if
  608.              the entire alloc is wanted! Notice that the first (or
  609.              last) byte in the string belongs to the structure and
  610.              not the 'string'!!! */
  611.   long len;      /* length of following string */
  612.   uchar string[1]; /* memory included in the string! */
  613. };
  614.  
  615.  
  616. struct fplVariable {
  617.   struct Identifier *ref; /* Used when passing variable references. */
  618.                           /* pointer to the "actual" identifier */
  619.  
  620.   long *dims;  /* An array holding the size of each dimension. */
  621.   long num;    /* Number of dimensions */
  622.   long size;   /* Number of variables in this array, that it is all
  623.           dims' members multiplied with each other! */
  624.  
  625.   long ID; /* set when using EXTERNAL_VARIABLEs from v10 */
  626.  
  627.   /*
  628.    * Variable values to read. This is an array of values if the variable
  629.    * was declared as an array!
  630.    */
  631.   union {
  632.     struct fplStr **str; /* FPL string  */
  633.     long *val32;    /* FPL integer */
  634.     short *val16;    /* FPL short   */
  635.     uchar *val8;    /* FPL char    */
  636.     void *val;        /* general FPL data pointer */
  637.   } var;
  638. };
  639.  
  640. struct Identifier {
  641.   /* This structure is used to store all identifiers in when they are "hashed
  642.      in". Notice that *ALL* data in this structure is pointing and referring
  643.      to the very same data as was sent to it, which means that you must keep
  644.      that data intact while using FPL. */
  645.  
  646.   uchar *name; /* Indentifier. Must be absolutely unique and not more than
  647.          MAX_COMMAND_LEN characters long. */
  648.  
  649.   union {
  650.     struct ExternalFunction external;
  651.     struct InsideFunction inside;
  652.     struct fplVariable variable;
  653.   } data;
  654.   
  655.   unsigned long flags; /* See below! */
  656.  
  657.   uchar *file;    /* file name of the file in which we find this identifier */
  658.   
  659.   struct Identifier *func; /* It exists only under this function. Pointer might
  660.                   be NULL if in no function! */
  661.  
  662.   long level; /* In which level this exists.
  663.          Variables exist in all levels below (with a higher number)
  664.          where it was declared. Two declarations using the same
  665.          name in the same level is not allowed!
  666.          LONG_MAX if global! */
  667.   
  668.   unsigned long hash; /* Hash value. To get the proper hash table entry for
  669.              this, use [hash%HASH_TABLE_SIZE] */
  670.   
  671.   /* Bidirectional links to keep a hash value sorted order among
  672.      functions using the same hash table entry: */
  673.   struct Identifier *prev;
  674.   struct Identifier *next;
  675. };
  676.  
  677. /****** Identifier.flags defines:  ******/
  678.  
  679. /* Data type */
  680.  
  681. #define FPL_STRING_VARIABLE   (1<<0)  /* string variable */
  682. #define FPL_INT_VARIABLE      (1<<1)  /* integer variable */
  683. #define FPL_REFERENCE         (1<<2)  /* identifier reference */
  684. #define FPL_INTERNAL_FUNCTION (1<<3)  /* internal FPL function */
  685. #define FPL_EXTERNAL_FUNCTION (1<<4)  /* user supplied external function */
  686. #define FPL_INSIDE_FUNCTION   (1<<5)  /* inside function in any program */
  687. #define FPL_KEYWORD          (1<<6)  /* this is a keyword identifier! */
  688. #define FPL_KEYWORD_DECLARE   (1<<7)  /* declaring keyword */
  689. #define FPL_INSIDE_NOTFOUND   (1<<8)  /* This inside function has not been
  690.                      discovered yet. The position the
  691.                      data points to is the search start
  692.                      position. */
  693. #define FPL_IGNORE            (1<<9) /* Read this and then drop it! */
  694. /* Data status */
  695.  
  696. #define FPL_READONLY          (1<<10) /* const variable! */
  697. #define FPL_EXTERNAL_VARIABLE (1<<11) /* external variable! new from V10 */
  698. #define FPL_EXPORT_SYMBOL     (1<<12) /* cross program accessible */
  699. #define FPL_GLOBAL_SYMBOL     (1<<13) /* global accessible in one file */
  700. #define FPL_SHORT_VARIABLE    (1<<14) /* short (16-bit) variable */
  701. #define FPL_CHAR_VARIABLE     (1<<15) /* char (8-bit) variable */
  702. #define FPL_UNSIGNED_VARIABLE (1<<16) /* unsigned variable */
  703. #define FPL_STATIC_VARIABLE   (1<<17) /* static variable! */
  704.  
  705. #define FPL_DEALLOC_NAME_ANYWAY (1<<18) /* In normal cases, this name should
  706.                                            not get freed, but this is not a
  707.                                            normal case... ;-P */
  708.  
  709. #define FPL_STATUS (FPL_READONLY|FPL_HIJACKED_VARIABLE|FPL_EXPORT_SYMBOL\
  710.             FPL_GLOBAL_SYMBOL|FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE\
  711.             FPL_UNSIGNED_VARIABLE|FPL_STATIC_VARIABLE|FPL_REFEREMCE)
  712.  
  713. /*
  714.  * These two lower flags should be combined with the "Data status" flags
  715.  * when declaring variables!
  716.  */
  717.  
  718. #define FPLDECL_STRING          (1<<31) /* Keyword declaring string */
  719. #define FPLDEC_INT          (1<<30) /* Keyword declaring int */
  720.  
  721.  
  722. #define FPL_VARIABLE_LESS32 (FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE)
  723. #define FPL_VARIABLE (FPL_STRING_VARIABLE|FPL_INT_VARIABLE)
  724. #define FPL_FUNCTION (FPL_INTERNAL_FUNCTION|FPL_EXTERNAL_FUNCTION |\
  725.               FPL_INSIDE_FUNCTION)
  726.  
  727. /***** Identifier.ID defines: ******/
  728.  
  729. struct Position {
  730.   /*
  731.    * This struct should be used from now on when storing and using the
  732.    * interpret position!
  733.    */
  734.   uchar *text;       /* Current interpret position */
  735.   long prg;         /* Current line number */
  736.   uchar *virfile;    /* virtual file name pointer */
  737.   long virprg;        /* virtual line number */
  738. };
  739.  
  740.  
  741. #define FPL_INSIDE_FUNCTION_ID -3;
  742.  
  743. struct Condition {
  744.   uchar *bracetext;  /* pointer to the character to the right of the open
  745.                brace */
  746.   long braceprg;    /* line number of the above data */
  747.   uchar *check;      /* pointer to the expression. Used by while() and for() */
  748.   long checkl;      /* the line number of the expression */
  749.   uchar *postexpr;   /* USED BY "for" : pointer to statement3 */
  750.   long postexprl;   /* USED BY "for" : statement3's line number */
  751. };
  752.  
  753. struct Expr {  /* the numerical expression linked list */
  754.   union {
  755.     long val;        /* numerical return */
  756.     struct fplStr *str; /* string return */
  757.   } val;
  758.   Operator operator;  /* see the operator enums! */
  759.   struct Unary *unary; /* unary/primary operators linked list! */
  760.   short flags;          /* see below */
  761.   struct Expr *next; 
  762. };
  763.  
  764. /**** struct Expr.flags defines: ****/
  765. #define FPL_STRING     (1<<0) /* Expr structure is a string. */
  766. #define FPL_NOFREE     (1<<1) /* A returned string should not be freed */
  767. #define FPL_OPERAND    (1<<2) /* Next part in the expression is a operand */
  768. #define FPL_ACTION     (1<<3) /* The expression includes any variable change(s) */
  769. #define FPL_BREAK      (1<<4) /* The val member specifies number of levels
  770.                  left to break from! */
  771. #define FPL_RETURN     (1<<5) /* There is a return call received, return to the
  772.                  last function caller. */
  773. #define FPL_CONTINUE   (1<<6) /* Continue is flagged! */
  774.  
  775. #define FPL_DEFUNCTION (1<<7) /* The Expression() just called declared AND
  776.                  defined a function! */
  777. #define FPL_BRACE      (1<<8) /* This invoke returned due to a closing brace! */
  778.  
  779. struct Local {
  780.   /*
  781.    * This structure will create a linked list of all local variables declared
  782.    * in this level. When leaving this level, *ALL* variables with the names
  783.    * that the ->ident member points to must be deleted, using DelIdentifier().
  784.    */
  785.   struct Identifier *ident;
  786.         /* This pointer points to the Identifier structure,
  787.            that means this should *NOT* be freed individually
  788.            but only the entire structure and the Identifier structure
  789.            (and members) at the same time! */
  790.   struct Local *next; /* Next member in this chain */
  791. };
  792.  
  793. /*
  794.  * All fplFunction ID's below zero are reserved for FPL internal use.
  795.  * We use the funcdata member to set some flags:
  796.  */
  797. #define FPL_HASH_INSIDE   1
  798. #define FPL_HASH_INTERNAL 2
  799.  
  800. struct Program {
  801.   struct Program *next;
  802.   uchar *name;        /* unique name of program */
  803.   long running;        /* true if running */
  804.   long openings;    /* number of invokes! */
  805.   uchar *program;    /* program pointer or NULL if not present in memory */
  806.   long lines;        /* number of lines */
  807.   long size;        /* total size in number of bytes */
  808.   long flags;        /* see defines below */
  809.  
  810.   long date;        /* date in seconds (system dependent) */
  811.  
  812.   char foundstart;    /* this program's "main" function is found! */
  813.   long startcol;    /* Where "main" started. Column number */
  814.   long startprg;    /* Where "main" started. Line number */
  815.   long virprg;        /* Virtual line number of "main" */
  816.   uchar *virfile;    /* virtual file name of "main" */
  817.   long column;        /* Last interpreted column!
  818.                _ONLY_ to read if this program isn't opened! */
  819.   long warnings;    /* number of warnings found in this file! */
  820.  
  821. #ifdef STRING_STACK
  822.   long strings_in_stack_max;
  823.   long strings_in_stack_now;
  824.   long stringstackptr;
  825.   struct StringStack **stringstack;
  826. #endif
  827.  
  828. };
  829.  
  830. /* Program.flags: */
  831. #define PR_USERSUPPLIED (1<<0)
  832. /* This program is user supplied. That means that FPL has *not* allocated the
  833.    memory this program uses, making no straight flushes allowed! */
  834.  
  835. #define PR_CACHEFILE (1<<1)
  836. /* This program should be cached until anything else is said! */
  837.  
  838. #define PR_FILENAMEFLUSH (1<<2)
  839. #define PR_NAME_IS_FILENAME PR_FILENAMEFLUSH
  840. /* When this program is flushed, it can always be restored by using the
  841.    program name as file name to read from! */
  842.  
  843. #define PR_TEMPORARY (1<<3)
  844. /* This isn't a real program but only created for a temporary usage reason! */
  845.  
  846. #define PR_GLOBALSTORED (1<<4)
  847. /* This program has got it's global symbols stored! */
  848.  
  849. #define PR_CACHEEXPORTS (1<<5)
  850. /* This program should be cached only if exports are declared */
  851.  
  852. #define PR_FLUSH_NOT_IN_USE (1<<6)
  853. /* This program should be flushed from memory when not in use, to save system
  854.    memory! */
  855.  
  856. #define PR_REREAD_CHANGES (1<<7)
  857. /* This program should be re-read into memory if accessed and the actual file
  858.    on disk has changed! */
  859.    
  860. #define PR_KIDNAP_CACHED (1<<8)
  861. /* This program should get kidnapped if it is PR_USERSUPPLIED and should get
  862.    cached! */
  863.  
  864. struct FuncList {
  865.   /*
  866.    * This struct is a general purpose linked list struct for keeping track
  867.    * of a list of char pointers.
  868.    */
  869.   struct FuncList *next;
  870.   long opens;
  871.   uchar flags;
  872.   uchar *name;
  873. };
  874.  
  875. struct Store {
  876.   /*
  877.    * This is all data that should be backuped when recursing, and
  878.    * restored when the recursing function ends.
  879.    */
  880.   uchar *text;
  881.   long prg;
  882.   uchar strret;
  883.   long level;
  884.   long varlevel;
  885.   uchar *virfile;
  886.   long virprg;
  887.   uchar *interpret;
  888.   struct Local *globals;
  889.   struct fplMsg *msg;
  890.   struct Program *prog;
  891.   struct Local *locals;
  892. };
  893.  
  894. struct Data {
  895.   /*
  896.    * Allocated at fplInit() and freed at fplFree().
  897.    */
  898. #ifdef AMIGA
  899.   uchar *stack_base;    /* our new stack base */
  900.   long stack_size;    /* requested stack size! */
  901.   long stack_max;    /* Maximum stack left after a FPL function call */
  902.   long stack_limit;    /* absolute maximum stack usage allowed */
  903.   long stack_margin;    /* minimum stack required to call the interface
  904.                function! */
  905.   long registers[11];    /* Storage for the eleven registers that should be
  906.                brought back when calling the interface function */
  907.   struct Task *task;    /* pointer to our task! */
  908.   uchar *old_topstack;   /* previous top stack in the task struct */
  909.   uchar *old_botstack;   /* previous bot stack in the task struct */
  910.   long extern_stack;    /* external stack pointer */
  911.   long intern_stack;    /* internal stack pointer */
  912.   struct FuncList *funclibs; /* a linked list with the current opened funclib
  913.                                 names */
  914. #endif
  915.   /* --------------------------------------------------------------------- */
  916.   /* If anything is changed among the above, check validity of liballoc.i! */
  917.   /* --------------------------------------------------------------------- */
  918.  
  919.   void * ASM (*Alloc)(DREG(0) long,
  920.                       AREG(0) void *);  /* allocate routine to use */
  921.   void ASM (*Dealloc)(AREG(1) void *,
  922.                       DREG(0) long,
  923.                       AREG(0) void *); /* dealloc routine */
  924.  
  925.   long ASM (*function) (AREG(0) void *); /* Pointer to function handler. */
  926.   long ASM (*interfunc) (AREG(0) void *); /* Function to be called every now
  927.                          and then when executing, enabling
  928.                          your programming to keep track of
  929.                          different things even if FPL is in
  930.                          charge! */
  931.  
  932.   /********* START OF STORE STRUCT ***********/
  933.   
  934.   uchar *text;       /* Current interpret position */
  935.   long prg;         /* Current line number */
  936.   uchar *virfile;    /* virtual file name pointer */
  937.   long virprg;        /* virtual line number */
  938.  
  939.   uchar strret;        /* The Script() now executing should return a
  940.                string! (TRUE/FALSE) */
  941.   long level;        /* Nesting level */
  942.   long varlevel;    /* current variable level */
  943.  
  944.   uchar *interpret;  /* if we whould interpret anything else but the main
  945.                function! Set this with the FPLTAG_INTERPRET tag. */
  946.  
  947.   struct Local *globals; /* Pointer to list holding all global symbols
  948.                 currently declared in this program. They might be
  949.                 removed when this program quits if the user has
  950.                 set that flag or if we miss certain information */
  951.  
  952.   struct fplMsg *msg; /* Pointer to any pending message to FPL sent from the
  953.              user. We expect return codes from user functions to
  954.              be sent using this. */
  955.  
  956.   struct Program *prog; /* Pointer to the "struct Program" holding information
  957.                about the program we're currently interpreting */
  958.  
  959.   struct Local *locals; /* Linked list of local variables! If any error
  960.                code is returned, there might be local variables
  961.                left to free in any precious local level! Use this
  962.                list to delete 'em all!
  963.                
  964.                We add *ALL* levels to one list, separated with a
  965.                NULL name. Deleting only the latest level, deletes
  966.                to the nearest NULL name!
  967.                */
  968.  
  969.   /********* END OF STORE STRUCT *************/
  970.  
  971.   struct Program *programs; /* list with all files information */
  972.   long ret;        /* Return value of the FPL block */
  973.   uchar *buf;        /* Global buffer pointer (Why use more than one buffer
  974.                at a time? It's only a waste of valuable stack!) */
  975.   void *userdata;       /* Global Userdata. Free to use. */
  976.   unsigned long flags;  /* Flags. See defines below! */
  977.   long data;            /* The result of the interfunc. */
  978.   long FPLret;            /* FPL return code = the result of the
  979.                "exit(RETURN_CODE);" call! */
  980.   long *returnint;    /* pointer to the above if an integer actually was
  981.                            returned */
  982.   long hash_size;    /* hash table size! */
  983.   struct Identifier **hash;  /* Must be set to NULL before doing anything
  984.                 major... like using fplAddFunction() or
  985.                 calling fplExecute[File]() The NULL-setting is
  986.                 done by fplInit(). */
  987.  
  988.   struct Local *usersym; /* Pointer to list holding all global symbols
  989.                 declared in another FPL program run. These symbols
  990.                 are legal global symbols */
  991.   
  992.   struct MemInfo *MallocKey[2]; /* We have two mallockey pointers because we
  993.                    have two different kinds of Malloc()s! One
  994.                    for each execution and one for each
  995.                    fplInit(). */
  996.   struct FreeBlock *blox[BLOCK_ENTRIES]; /* memory caching tables */
  997.   long blockcount[BLOCK_ENTRIES]; /* memory caching table counters */
  998.   struct Identifier *func; /* pointer to the current interpreted function
  999.                   or NULL */
  1000.   long runs;
  1001.   uchar **string_return;  /* whether this program should allow strings to be
  1002.                 returned to the host program (set with the
  1003.                 FPLTAG_STRING_RETURN tag to 'fplExecuteXXX()'). */
  1004.   uchar *identifier;    /* host program identifier. This should point to
  1005.                  a unique string to enable separation between
  1006.                  different processes use of FPL library functions! */
  1007.   void *debugentry;    /* used by the debugger alone! *Hands off!* */
  1008.   uchar *error;          /* pointer to error message buffer or NULL */
  1009.  
  1010.   long breaks; /* number of levels possible to break! Each nested for, do,
  1011.                   while and switch increases, each end of the same decreases
  1012.                   as well as break, return and exit */
  1013.  
  1014. #define ADDBUFFER_SIZE 32 /* buffered size; before appending string */
  1015.  
  1016.   uchar addchar_buffer[ADDBUFFER_SIZE];
  1017.   long addchar_len;
  1018. #ifdef AMIGA
  1019.   struct Library *FPLBase; /*
  1020.                             * Pointer to our own library base.
  1021.                             * Could become handy for the debugger and/or other
  1022.                             * external programs to control FPL internal
  1023.                             * affairs!!
  1024.                             */
  1025. #endif                             
  1026. };
  1027.  
  1028. /***** Data.flags: *****/
  1029.  
  1030. #define FPLDATA_ALLFUNCTIONS (1<<0)
  1031. /* Accept all functions, even if not found! */
  1032.  
  1033. #define FPLDATA_CACHEFILE (1<<1)
  1034. /* This file should be cached among the other global data. */
  1035.  
  1036. #define FPLDATA_CACHEALLFILES (1<<2)
  1037. /* This makes FPL store all files in memory that it has to remember */
  1038.  
  1039. #define FPLDATA_CACHEEXPORTS (1<<3)
  1040. /* This makes FPL store all files in memory that exports symbols */
  1041.  
  1042. #define FPLDATA_NESTED_COMMENTS (1<<6)
  1043. /* Allow nested comments */
  1044.  
  1045. #define FPLDATA_REREAD_CHANGES (1<<7)
  1046. /* Mark all files by default to get reread into memory when its accessed
  1047.    and the actual file is changed on disk, the symbols
  1048.    for that file will be removed and the file re-read into memory! */
  1049.  
  1050. #define FPLDATA_FLUSH_NOT_IN_USE (1<<8)
  1051. /* Mark all files by default to be flushed from memory when not used! */
  1052.  
  1053. #define FPLDATA_DEBUG_MODE (1<<9) /* currently running in debug mode! */
  1054. #define FPLDATA_DEBUG_GLOBAL (1<<10) /* always debug mode! */
  1055.  
  1056. #define FPLDATA_DEBUG (FPLDATA_DEBUG_MODE|FPLDATA_DEBUG_GLOBAL)
  1057.  
  1058. #define FPLDATA_KIDNAP_CACHED (1<<11) /* kidnap mode default */
  1059.  
  1060. #define FPLDATA_PREVENT_RUNNING_SAME (1<<12) /* never execute a file that is
  1061.                         cached and hasn't been changed
  1062.                         since last execution */
  1063.  
  1064. #define FPLDATA_ISOLATE (1<<13) /* this script cannot export symbols, nor
  1065.                                    can it access other exported symbols! */
  1066.  
  1067. struct fplMsg {
  1068.   struct fplMsg *next;  /* next message struct */
  1069.   struct fplMsg *prev;    /* when priority is allowed, things might be inserted
  1070.                virtually anywhere in the list */
  1071.   uchar type;        /* type of message. See defined below! */
  1072.   void *message[1];    /* different meanings depending on the type */
  1073.   uchar flags;        /* new from version 12.6 */
  1074. };
  1075.  
  1076. /* When the FPLMSG_RETURN type is used, these 'flags' bits tell which type
  1077.    that actually was returned! */
  1078. #define FPLMSG_FLG_STRING (1<<0)
  1079. #define FPLMSG_FLG_INT    (1<<1)
  1080. #define FPLMSG_FLG_BITS (FPLMSG_FLG_STRING | FPLMSG_FLG_INT)
  1081.  
  1082.  
  1083. #define FPLMSG_RETURN         1 /* general return type message, see the 'flags'
  1084.                    field for data type! */
  1085. #define FPLMSG_STOP          3 /* message[0] is to be stored in Data->data
  1086.                    as the "result of the last interfunc". */
  1087. #define FPLMSG_PROGRAM          4 /* message[0] is a (uchar **) to the program
  1088.                    array, message[1] is zero or the new number
  1089.                    of lines and message[2] is zero or the new
  1090.                    program size. */
  1091. #define FPLMSG_CONFIRM          5 /* message[0] is TRUE/FALSE */
  1092. #define FPLMSG_GLOBAL          6 /* Global symbol reading is ordered.
  1093.                    (FPLSEND_GLOBALSYMBOLS)
  1094.                    message[0] holds the current pointer to a
  1095.                    struct Local */
  1096.  
  1097.  
  1098. /**********************************************************************
  1099.  *                                                                    *
  1100.  * All functions used from external functions.                        *
  1101.  *                                                                    *
  1102.  **********************************************************************/
  1103.  
  1104. ReturnCode PREFIX fplExecuteScript(AREG(0) struct Data *,
  1105.                    AREG(1) uchar **,
  1106.                    DREG(1) long,
  1107.                    AREG(2) unsigned long *);
  1108. ReturnCode PREFIX fplExecuteFile(AREG(0) struct Data *,
  1109.                  AREG(1) uchar *,
  1110.                  AREG(2) unsigned long *);
  1111. uchar * PREFIX fplGetErrorMsg(AREG(0) struct Data *,
  1112.                  DREG(0) long,
  1113.                  AREG(1) uchar *);
  1114. void * ASM fplInit(AREG(0) long (*)(void *),
  1115.            AREG(1) unsigned long *);
  1116. void PREFIX fplFree(AREG(0) struct Data *);
  1117. ReturnCode PREFIX fplAddFunction(AREG(0) struct Data *,
  1118.                  AREG(1) uchar *,
  1119.                  DREG(0) long,
  1120.                  DREG(1) uchar,
  1121.                  AREG(2) uchar *,
  1122.                  AREG(3) unsigned long *);
  1123. ReturnCode PREFIX fplDelFunction(AREG(0) struct Data *,
  1124.                  AREG(1) uchar *);
  1125. ReturnCode PREFIX fplReset(AREG(0) struct Data *,
  1126.                AREG(1) unsigned long *);
  1127. ReturnCode PREFIX fplSend(AREG(0) struct Data *,
  1128.               AREG(1) unsigned long *);
  1129. void PREFIX *fplAlloc(AREG(0) struct Data *,
  1130.               DREG(0) long);
  1131. void PREFIX fplDealloc(AREG(0) struct Data *,
  1132.                AREG(1) void *);
  1133. void PREFIX *fplAlloca(AREG(0) struct Data *,
  1134.                DREG(0) long);
  1135. void PREFIX fplDealloca(AREG(0) struct Data *,
  1136.                 AREG(1) void *);
  1137. long PREFIX fplConvertString(AREG(0) struct Data *,
  1138.                  AREG(1) uchar *,
  1139.                  AREG(2) uchar *);
  1140. ReturnCode PREFIX fplCallFunction(AREG(0) struct Data *,
  1141.                   AREG(1) uchar *,
  1142.                   DREG(0) long,
  1143.                   AREG(2) void **,
  1144.                   AREG(3) uchar *format,
  1145.                   AREG(4) unsigned long *);
  1146.  
  1147. void PREFIX *fplAllocString(AREG(0) struct Data *,
  1148.                 DREG(0) long);
  1149. void PREFIX fplFreeString(AREG(0) struct Data *,
  1150.               AREG(1) void *);
  1151.  
  1152. #ifdef AMIGA
  1153. long PREFIX fplOpenLib(AREG(0) struct Data *,
  1154.                        AREG(1) uchar *,
  1155.                        DREG(0) long,
  1156.                        DREG(1) long);
  1157. long PREFIX fplCloseLib(AREG(0) struct Data *,
  1158.                         AREG(1) uchar *,
  1159.                         DREG(0) long);
  1160. #endif
  1161.  
  1162. ReturnCode PREFIX fplAddVariable(AREG(0) struct Data *,
  1163.                                  AREG(1) uchar *,
  1164.                                  DREG(0) long,
  1165.                                  DREG(1) uchar,
  1166.                                  AREG(2) void *,
  1167.                                  AREG(3) unsigned long *);
  1168.  
  1169. ReturnCode PREFIX fplReference(AREG(0) struct Data *,
  1170.                                AREG(1) struct Identifier *,
  1171.                                AREG(2) unsigned long *);
  1172.  
  1173. /**********************************************************************
  1174.  * All functions used globally in the library.                        *
  1175.  **********************************************************************/
  1176. ReturnCode ASM Script(AREG(2) struct Data *,
  1177.                       AREG(3) struct Expr *,
  1178.                       DREG(2) short,
  1179.                       AREG(1) struct Condition *);
  1180. ReturnCode  REGARGS Expression(struct Expr *, struct Data *, long, struct Identifier *);
  1181. ReturnCode  REGARGS Eat(struct Data *);
  1182. ReturnCode  REGARGS Getword(struct Data *);
  1183.  
  1184. uchar * REGARGS GetErrorMsg(struct Data *, long, uchar *);
  1185.  
  1186. #ifdef UNIX
  1187. /* The Amiga version has this function coded in assembler */
  1188. long InterfaceCall(struct Data *, void *, long (*)(void *));
  1189. #define InterfaceCallNoStack InterfaceCall /* make them call the same func */
  1190. #endif
  1191.  
  1192. ReturnCode  REGARGS DelProgram(struct Data *, struct Program *);
  1193. ReturnCode  REGARGS ReadFile(void *, uchar *, struct Program *);
  1194. ReturnCode  REGARGS Newline(struct Data *);
  1195. long  REGARGS Strtol(uchar *, long, uchar **);
  1196.  
  1197. ReturnCode  REGARGS NewMember(struct Data *, struct Expr **);
  1198. ReturnCode  REGARGS AddVar(struct Data *, struct Identifier *, struct Local **);
  1199. ReturnCode  REGARGS ReturnChar(struct Data *, long *, uchar);
  1200. ReturnCode  REGARGS GetEnd(struct Data *, uchar, uchar, uchar);
  1201. ReturnCode  REGARGS CmpAssign(struct Data *, long, long *, long, uchar);
  1202. ReturnCode  REGARGS StrAssign(struct fplStr *, struct Data *, struct fplStr **, uchar);
  1203. ReturnCode REGARGS AppendStringToString(struct Data *, struct fplStr **,
  1204.                     uchar *, long);
  1205. ReturnCode REGARGS Send(struct Data *, unsigned long *);
  1206. ReturnCode  REGARGS GetProgram(struct Data *, struct Program *);
  1207. ReturnCode  REGARGS LeaveProgram(struct Data *, struct Program *);
  1208. ReturnCode  REGARGS Warn(struct Data *, ReturnCode);
  1209.  
  1210. ReturnCode  REGARGS DeleteMessage(struct Data *, struct fplMsg *);
  1211. ReturnCode  REGARGS GetMessage(struct Data *, uchar, struct fplMsg **);
  1212. ReturnCode  REGARGS functions(struct fplArgument *);
  1213.  
  1214. ReturnCode REGARGS RenameIdentifier(struct Data *,
  1215.              struct Identifier *,   /* existing identifier */
  1216.              uchar *);   /* new name */
  1217. ReturnCode  REGARGS GetIdentifier(struct Data *, uchar *, struct Identifier **);
  1218. ReturnCode  REGARGS DelIdentifier(struct Data *, uchar *, struct Identifier *);
  1219. void ASM *DefaultAlloc(DREG(0) long, AREG(0) void *);
  1220. void ASM DefaultDealloc(AREG(1) void *, DREG(0) long, AREG(0) void *);
  1221. ReturnCode  REGARGS DelLocalVar(struct Data *, struct Local **);
  1222. ReturnCode  REGARGS AddLevel(struct Data *);
  1223. long REGARGS ArrayNum(long, long, long *, long *);
  1224. ReturnCode REGARGS ArrayResize(struct Data *, long, long *,
  1225.                                struct Identifier *);
  1226.  
  1227. uchar REGARGS TypeMem(void *);
  1228. void  REGARGS SwapMem(struct Data *, void *, uchar);
  1229. void ASM Free(AREG(0) struct Data *, AREG(1) void *, DREG(0) uchar);
  1230. void  REGARGS FreeCycle(struct Data *, void *);
  1231. void  REGARGS FreeAll(struct Data *, uchar);
  1232. void ASM *Malloc(AREG(0) struct Data *, DREG(0) long, DREG(1) uchar DEBUGPARAMETERS1);
  1233. void  *MallocCycle(struct Data *, long DEBUGPARAMETERS2);
  1234. void  REGARGS InitFree(struct Data *);
  1235. void  REGARGS FlushFree(struct Data *);
  1236. void  REGARGS CleanUp(struct Data *, long, long);
  1237. long REGARGS BitToggle(long, long, long);
  1238. void REGARGS FreeKind(struct Data *, void *);
  1239.  
  1240. ReturnCode REGARGS ScanForNext(struct Data *,
  1241.                                Operator); /* previous operator */
  1242.  
  1243. ReturnCode REGARGS Sprintf(struct Data *, struct fplStr **, uchar *,
  1244.                            void **, uchar *, long);
  1245. ReturnCode REGARGS StringExpr(struct Expr *, struct Data *);
  1246.  
  1247. ReturnCode REGARGS AddCharBuffer(struct Data *, struct fplStr **, long);
  1248. #define ADD_RESET -1 /* reset buffer */
  1249. #define ADD_FLUSH -2 /* flush buffer */
  1250.  
  1251. long
  1252. Sscanf(struct Data *, uchar *, uchar *, long, void **, uchar *);
  1253.  
  1254. #ifdef DEBUG
  1255. ReturnCode REGARGS CheckMem(struct Data *, void *);
  1256. #endif
  1257.  
  1258. #if defined(AMIGA)
  1259.  /*
  1260.   * These are functions for funclibs only:
  1261.   */
  1262.  
  1263. ReturnCode REGARGS OpenLib(struct Data *, uchar *, long, long *, uchar);
  1264. ReturnCode REGARGS CloseLib(struct Data *, uchar *, long, long *);
  1265.  
  1266. #endif
  1267.